package com.mc.main;

import java.net.SocketException;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Monitor dummy
 * 
 * @author Mikael Bertlin
 *
 */

public class MonitorDummy extends Activity{
	
	private UnitAccessDummy uad;
	private UdpClient client;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.md_layout);
		
		client = UdpClient.client;
		uad = new UnitAccessDummy(client);
		client.addUdpEventListener(uad);
		client.startListen();

		TextView tv = (TextView) findViewById(R.id.TextViewTemp);
		String s =  Integer.toString(uad.getTemp());
	    tv.setText("Current temp: " + s);
	    
	    final Button button = (Button) findViewById(R.id.ButtonRefresh);
		button.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				TextView tv = (TextView) findViewById(R.id.TextViewTemp);
				String s =  Integer.toString(uad.getTemp());
			    tv.setText("Current temp: " + s);	
			}
			
		});
	}

}
